d/tests/run-with-locales: Move from d/run-with-locales
authorSimon McVittie <smcv@debian.org>
Wed, 4 Nov 2020 10:59:15 +0000 (10:59 +0000)
committerSimon McVittie <smcv@debian.org>
Wed, 4 Nov 2020 10:59:15 +0000 (10:59 +0000)
This makes tab-completion for d/rules work better.

debian/rules
debian/run-with-locales [deleted file]
debian/tests/installed-tests
debian/tests/installed-tests-flaky
debian/tests/run-with-locales [new file with mode: 0755]

index ee235179afd92b7797e3dbf20ba5405cb65a9b6f..7eaf8c7726f2baa415440e0b060181639ee23d17 100755 (executable)
@@ -190,7 +190,7 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
        env -u LD_PRELOAD \
        dbus-run-session -- \
        xvfb-run -a -s "-screen 0 1024x768x24" \
-       debian/run-with-locales \
+       debian/tests/run-with-locales \
                --generate de_DE.UTF-8 \
                --generate en_GB.UTF-8 \
                --generate en_US.UTF-8 \
diff --git a/debian/run-with-locales b/debian/run-with-locales
deleted file mode 100755 (executable)
index a63d22b..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/bin/sh
-#
-# Run a wrapped command with at least the requested locales available.
-# Requires a dependency on locales | locales-all.
-# The requested locales must be of the form foo_FOO.utf8, or special-cased
-# in generate().
-#
-# Copyright 2016-2020 Simon McVittie
-# Copyright 2017-2018 Collabora Ltd.
-#
-# SPDX-License-Identifier: MIT
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-# IN THE SOFTWARE.
-
-# Assume a Debian Policy §10.4-compatible shell like dash or bash (with the
-# 'local' builtin)
-# shellcheck disable=SC2039
-
-set -eu
-
-me="$(basename "$0")"
-tempdir=
-
-usage () {
-    local status="${1-2}"
-
-    if [ "$status" -ne 0 ]; then
-        exec >&2
-    fi
-
-    echo "Usage: $me [--generate LOCALE...] [--] COMMAND [ARGS...]"
-    exit "$status"
-}
-
-getopt_temp=help
-getopt_temp="$getopt_temp,generate:"
-
-getopt_temp="$(getopt -o '+' --long "$getopt_temp" -n "$0" -- "$@")"
-eval set -- "$getopt_temp"
-unset getopt_temp
-
-generate () {
-    local locale="$1"
-    local charset
-    local source
-    local output
-
-    echo "$me: $locale..." >&2
-
-    case "$locale" in
-        (*.*)
-            source="${locale%.*}"
-            output="$source.$(
-                export LC_ALL=C
-                printf '%s' "${locale##*.}" | \
-                    tr '[:upper:]' '[:lower:]' | \
-                    tr -d -C '[:lower:][:digit:]'
-            )"
-            ;;
-
-        (*)
-            source="${locale}"
-            output="${locale}"
-    esac
-
-    if [ -e "/usr/lib/locale/$output/LC_MESSAGES/SYS_LC_MESSAGES" ]; then
-        printf '\t%s\n' "Found in locales-all" >&2
-        return
-    fi
-
-    case "$locale" in
-        (*.utf8)
-            charset="UTF-8"
-            ;;
-
-        (*)
-            charset=$(sed -ne "s/^$locale //p" /usr/share/i18n/SUPPORTED)
-            ;;
-    esac
-
-    if [ -z "$charset" ]; then
-        echo "$me: $locale not found in /usr/share/i18n/SUPPORTED" >&2
-        exit 1
-    fi
-
-    printf '\t%s\n' "Character set: $charset" >&2
-    printf '\t%s\n' "Source file: $source" >&2
-
-    if [ -z "$tempdir" ]; then
-        tempdir="$(mktemp -d)"
-        trap 'rm -fr "$tempdir"' EXIT
-    fi
-
-    printf '\t%s\n' "Output: $tempdir/$output" >&2
-
-    localedef -i "$source" -f "$charset" "$tempdir/$output"
-}
-
-while [ "$#" -gt 0 ]; do
-    case "$1" in
-        (--help)
-            usage 2
-            # not reached
-            ;;
-
-        (--generate)
-            generate "$2"
-            shift 2
-            ;;
-
-        (--)
-            shift
-            break
-            ;;
-
-        (-*)
-            echo "$me: Unknown option: $1" >&2
-            usage 2
-            # not reached
-            ;;
-
-        (*)
-            break
-            ;;
-    esac
-done
-
-if [ -n "$tempdir" ]; then
-    export LOCPATH="$tempdir"
-fi
-
-"$@"
-
-# vim:set sw=4 sts=4 et:
index 126cabba91723b315ee88c49bf7fc38565248b11..36e24c3a37cd4b5a548e1e04c4b9ae59a985fec0 100755 (executable)
@@ -26,7 +26,7 @@ tests=$(gnome-desktop-testing-runner -l gtk-4.0 |
 
 exec dbus-run-session -- \
 xvfb-run -a -s "-screen 0 1024x768x24" \
-debian/run-with-locales \
+debian/tests/run-with-locales \
     --generate de_DE.UTF-8 \
     --generate en_GB.UTF-8 \
     --generate en_US.UTF-8 \
index 94e127e71158a6f90b2f91261fe56b6c43905327..c76968b38c6abae20fe84068dc422b0642d0c881 100755 (executable)
@@ -17,7 +17,7 @@ export GDK_BACKEND=x11
 
 exec dbus-run-session -- \
 xvfb-run -a -s "-screen 0 1024x768x24" \
-debian/run-with-locales \
+debian/tests/run-with-locales \
     --generate de_DE.UTF-8 \
     --generate en_GB.UTF-8 \
     --generate en_US.UTF-8 \
diff --git a/debian/tests/run-with-locales b/debian/tests/run-with-locales
new file mode 100755 (executable)
index 0000000..a63d22b
--- /dev/null
@@ -0,0 +1,150 @@
+#!/bin/sh
+#
+# Run a wrapped command with at least the requested locales available.
+# Requires a dependency on locales | locales-all.
+# The requested locales must be of the form foo_FOO.utf8, or special-cased
+# in generate().
+#
+# Copyright 2016-2020 Simon McVittie
+# Copyright 2017-2018 Collabora Ltd.
+#
+# SPDX-License-Identifier: MIT
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+# Assume a Debian Policy §10.4-compatible shell like dash or bash (with the
+# 'local' builtin)
+# shellcheck disable=SC2039
+
+set -eu
+
+me="$(basename "$0")"
+tempdir=
+
+usage () {
+    local status="${1-2}"
+
+    if [ "$status" -ne 0 ]; then
+        exec >&2
+    fi
+
+    echo "Usage: $me [--generate LOCALE...] [--] COMMAND [ARGS...]"
+    exit "$status"
+}
+
+getopt_temp=help
+getopt_temp="$getopt_temp,generate:"
+
+getopt_temp="$(getopt -o '+' --long "$getopt_temp" -n "$0" -- "$@")"
+eval set -- "$getopt_temp"
+unset getopt_temp
+
+generate () {
+    local locale="$1"
+    local charset
+    local source
+    local output
+
+    echo "$me: $locale..." >&2
+
+    case "$locale" in
+        (*.*)
+            source="${locale%.*}"
+            output="$source.$(
+                export LC_ALL=C
+                printf '%s' "${locale##*.}" | \
+                    tr '[:upper:]' '[:lower:]' | \
+                    tr -d -C '[:lower:][:digit:]'
+            )"
+            ;;
+
+        (*)
+            source="${locale}"
+            output="${locale}"
+    esac
+
+    if [ -e "/usr/lib/locale/$output/LC_MESSAGES/SYS_LC_MESSAGES" ]; then
+        printf '\t%s\n' "Found in locales-all" >&2
+        return
+    fi
+
+    case "$locale" in
+        (*.utf8)
+            charset="UTF-8"
+            ;;
+
+        (*)
+            charset=$(sed -ne "s/^$locale //p" /usr/share/i18n/SUPPORTED)
+            ;;
+    esac
+
+    if [ -z "$charset" ]; then
+        echo "$me: $locale not found in /usr/share/i18n/SUPPORTED" >&2
+        exit 1
+    fi
+
+    printf '\t%s\n' "Character set: $charset" >&2
+    printf '\t%s\n' "Source file: $source" >&2
+
+    if [ -z "$tempdir" ]; then
+        tempdir="$(mktemp -d)"
+        trap 'rm -fr "$tempdir"' EXIT
+    fi
+
+    printf '\t%s\n' "Output: $tempdir/$output" >&2
+
+    localedef -i "$source" -f "$charset" "$tempdir/$output"
+}
+
+while [ "$#" -gt 0 ]; do
+    case "$1" in
+        (--help)
+            usage 2
+            # not reached
+            ;;
+
+        (--generate)
+            generate "$2"
+            shift 2
+            ;;
+
+        (--)
+            shift
+            break
+            ;;
+
+        (-*)
+            echo "$me: Unknown option: $1" >&2
+            usage 2
+            # not reached
+            ;;
+
+        (*)
+            break
+            ;;
+    esac
+done
+
+if [ -n "$tempdir" ]; then
+    export LOCPATH="$tempdir"
+fi
+
+"$@"
+
+# vim:set sw=4 sts=4 et: